<?php
header("Content-Type: text/html; charset=utf-8");
include_once 'menu.php';

$action=$_GET['action'];
  if($action=="add"){
	$parentId=$_POST["parentId"];
	$menuName=$_POST["menuName"];	
	$menuUrl=$_POST["menuUrl"];	  
	$ret=menu_add( $parentId,$menuName,$menuUrl);	
	
	if($ret!=true){
		echo "<script>alert('新增失败！');</script>";	
	}else{
		echo "<script>alert('新增成功！');</script>";	
	}
	echo ("<script>document.location='menuCatalog.php';</script>");	
}else{
	$catListAll=list_menu();
} 
 
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>菜单分类新增</title>
<link rel="stylesheet" type="text/css" href="../skin/css/base.css">
<style type="text/css">
.catLog{margin: 20px; padding-top:5px;}
.catLog select { width:300px; }
.catLog input.txtInput{width:300px; }
.catLog input.btSubmit{ margin-left:170px; margin-top:6px;}
</style>
</head>
<body leftmargin="8" topmargin="8" background='../skin/images/allbg.gif'>
<form action="menuAdd.php?action=add" method="post">
<div class="catLog" >
	菜单名称:&nbsp;<input id="menuName" name="menuName"  class="txtInput" /><br />
	菜单Url:&nbsp;<input id="menuUrl" name="menuUrl"  class="txtInput" /><br />
	所属父类:&nbsp;<select id="parentId" name="parentId">
		<option value="0">无父类</option>
		<?php 
		foreach ($catListAll as $item) {
			 
			 
			?>
				<option        value="<?=$item->id ?>"><?=$item->menu_name ?></option>
		 	<?php  
 			 
		}
		?>
	</select><br />
<input type="submit" class="btSubmit" value="提交" /> <br />
 
</div>
</form>
</body>
</html>
